package burubaka.model;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

import com.google.appengine.api.datastore.Key;

/**
 * @author tk
 * 
 */
@Model(schemaVersion = 1)
public class ResultHorse implements Serializable {

	private static final long serialVersionUID = 1L;

	@Attribute(primaryKey = true)
	private Key key;

	@Attribute(version = true)
	private Long version;

	private Date createdDate = new Date();
	private String finishPoint;
	private String waku;
	private String horseNo;
	private String horseName = "";
	private String horseNameA = "";
	private String sexAge = "";
	private String weight = "";
	private String jockey = "";

	/**
	 * Returns the key.
	 * 
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * Sets the key.
	 * 
	 * @param key
	 *            the key
	 */
	public void setKey(Key key) {
		this.key = key;
	}

	/**
	 * Returns the version.
	 * 
	 * @return the version
	 */
	public Long getVersion() {
		return version;
	}

	/**
	 * Sets the version.
	 * 
	 * @param version
	 *            the version
	 */
	public void setVersion(Long version) {
		this.version = version;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public void setFinishPoint(String finishPoint) {
		if (StringUtils.isNotEmpty(finishPoint) && NumberUtils.isNumber(finishPoint) && finishPoint.length() == 1) {
			finishPoint = "0" + finishPoint;
		} else {
			finishPoint = "99";
		}
		this.finishPoint = finishPoint;
	}

	public String getFinishPoint() {
		return finishPoint;
	}

	public int getFinishPointNum() {
		return Integer.parseInt(finishPoint);
	}

	public String getWaku() {
		return waku;
	}

	public void setWaku(String waku) {
		this.waku = waku;
	}

	public String getHorseNo() {
		return horseNo;
	}

	public int getHorseNum() {
		return Integer.parseInt(horseNo);
	}

	public void setHorseNo(String horseNo) {
		if (StringUtils.isNotEmpty(horseNo) && horseNo.length() == 1) {
			horseNo = "0" + horseNo;
		}
		this.horseNo = horseNo;
	}

	public String getHorseName() {
		return horseName;
	}

	public void setHorseName(String horseName) {
		this.horseName = horseName;
	}

	public String getHorseNameA() {
		return horseNameA;
	}

	public void setHorseNameA(String horseNameA) {
		this.horseNameA = horseNameA;
	}

	public String getSexAge() {
		return sexAge;
	}

	public void setSexAge(String sexAge) {
		this.sexAge = sexAge;
	}

	public String getWeight() {
		return weight;
	}

	public void setWeight(String weight) {
		this.weight = weight;
	}

	public String getJockey() {
		return jockey;
	}

	public void setJockey(String jockey) {
		this.jockey = jockey;
	}

}
